package problem300;

//300.最长递增子序列
//https://leetcode.cn/problems/longest-increasing-subsequence/

class Solution {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        for(int i = 0; i<n; i++) {
            dp[i] = 1;
        }
        int ret = dp[0];
        for(int i = 1; i<n; i++) {
            for(int j = i-1; j>=0; j--) {
                if(nums[j] < nums[i]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            ret = Math.max(ret, dp[i]);
        }
        return ret;
    }
}